<!DOCTYPE html>
<html>

	<head>
		<!-- 声明文档使用的字符编码 -->
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<!-- 为移动设备添加 viewport -->
		<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
		<!-- 针对手持设备优化，主要是针对一些老的不识别viewport的浏览器，比如黑莓 -->
		<meta name="HandheldFriendly" content="true">
		<!-- 优先使用 IE 最新版本和 Chrome -->
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

		<title>黑图视界</title>
		<meta name="keywords" content="黑图视界">
		<meta name="description" content="黑图视界">
		<script type="text/javascript" src="../js/setFontSize.js"></script>
		<script type="text/javascript" src="../js/layui/layui.js" ></script>
		<link rel="stylesheet" href="../js/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../css/swiper.min.css" />
		<link rel="stylesheet" href="../css/main.css" />
	</head>

	<body>
		<main id="app">
			<section class="buyTicket picBg">
				<div class="container">
					<ul class="list whiteBg radius20 pad30">
						<li class="listItem clearfix" v-for="ticket in ticketList">
							<div class="icon iconCR"></div>
							<div class="text">
								<h6 class="name">{{ticket.name}}</h6>
								<div class="price">￥{{ticket.price}}</div>
							</div>
							<a class="buy" @click="ticketDetail(ticket.id)">修改详情</a>
							<a class="buy" @click="ticketDelete(ticket.id)">删除</a>
						</li>
					</ul>
					<div id="test1" style="text-align: center"></div>
				</div>

				<div class="asideBox">
					<div class="container">
						<a class="asideBtn" @click="add">增加</a>
					</div>
				</div>
			</section>
		</main>
		<script type="text/javascript" src="../js/jquery-3.3.1.min.js"></script>
		<script type="text/javascript" src="../js/swiper.min.js"></script>
		<script type="text/javascript" src="../js/layer/layer.js" ></script>
		<script type="text/javascript" src="../js/main.js"></script>
		<script src="../js/axios.js"></script>
		<script src="../js/vue.js"></script>
		<script src="../js/getParameter.js"></script>
		<script>
			let gid = getParameter("gid");
			if (gid===null) location.href = "myGymList.html"
			let app=new Vue({
				el:"#app",
				data:{
					ticketList:[]
				},
				methods:{
					loadTickets(){
						axios.get("/ticket/loadManagerTicket/"+gid).then(function (res) {
							if (res.data===""){
								location.href = "/managerclient/myGymList.html"
								layer.msg("查询错误")
							}
							app.ticketList = res.data
						})
					},
					ticketDetail(tid){
						location.href = "/managerclient/ticketDetail.html?tid="+tid
					},
					add(){
						location.href = "/managerclient/ticketAdd.html?gid="+gid
					},
					ticketDelete(tid){
						axios.delete("/ticket/delete/"+tid).then(function (res) {
							if (res.data==="success") layer.msg("删除成功")
							app.loadTickets();
						})
					}
				},
				created(){
					this.loadTickets();
				}
			})
		</script>

	</body>

</html>